home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / MosaicSRC / libwww2 / HTList.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  1.9 KB  |  62 lines

  1. /*  */
  2.  
  3. /*              List object
  4. **
  5. **      The list object is a generic container for storing collections
  6. **      of things in order.
  7. */
  8. #ifndef HTLIST_H
  9. #define HTLIST_H
  10.  
  11. #include "HTUtils.h"  /* for BOOL type and PARAMS and ARGS*/
  12.  
  13. typedef struct _HTList HTList;
  14.  
  15. struct _HTList {
  16.   void * object;
  17.   HTList * next;
  18.   HTList * last;
  19. };
  20.  
  21. #ifdef SHORT_NAMES
  22. #define HTList_new                      HTLiNew
  23. #define HTList_delete                   HTLiDele
  24. #define HTList_addObject                HTLiAdOb
  25. #define HTList_removeObject             HTLiReOb
  26. #define HTList_removeLastObject         HTLiReLa
  27. #define HTList_removeFirstObject        HTLiReFi
  28. #define HTList_count                    HTLiCoun
  29. #define HTList_indexOf                  HTLiInOf
  30. #define HTList_objectAt                 HTLiObAt
  31. #endif
  32.  
  33. extern HTList * HTList_new NOPARAMS;
  34. extern void     HTList_delete PARAMS((HTList *me));
  35.  
  36. /*      Add object to START of list
  37. */
  38. extern void     HTList_addObject PARAMS((HTList *me, void *newObject));
  39. extern void     HTList_addObjectAtEnd PARAMS((HTList *me, void *newObject));
  40.  
  41.  
  42. extern BOOL     HTList_removeObject PARAMS((HTList *me, void *oldObject));
  43. extern void *   HTList_removeLastObject PARAMS((HTList *me));
  44. extern void *   HTList_removeFirstObject PARAMS((HTList *me));
  45. #define         HTList_isEmpty(me) (me ? me->next == NULL : YES)
  46. extern int      HTList_count PARAMS((HTList *me));
  47. extern int      HTList_indexOf PARAMS((HTList *me, void *object));
  48. #define         HTList_lastObject(me) \
  49.   (me && me->next ? me->next->object : NULL)
  50. extern void *   HTList_objectAt PARAMS((HTList *me, int position));
  51.  
  52. /* Fast macro to traverse the list. Call it first with copy of list header :
  53.    it returns the first object and increments the passed list pointer.
  54.    Call it with the same variable until it returns NULL. */
  55. #define HTList_nextObject(me) \
  56.   (me && (me = me->next) ? me->object : NULL)
  57.  
  58. #endif /* HTLIST_H */
  59. /*
  60.  
  61.     */
  62.